/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Facades;

import Entities.Rol;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author roycalderon
 */
@Stateless
public class RolFacade extends AbstractFacade<Rol> {

    @PersistenceContext(unitName = "MaRoY-LibraryPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RolFacade() {
        super(Rol.class);
    }

    public Rol findByRolidRol(int rolid) {
        Query query = em.createNamedQuery("Rol.findByIdRol");
        query.setParameter("idRol", rolid);
        Rol aux;
        try {
            aux = (Rol) query.getSingleResult();
            if (aux != null) {
                return aux;
            } else {
                return null;
            }
        } catch (Exception e) {
        }
        return null;
    }
}
